package androidlab.sprintingsquirrel.splash;

import org.andengine.engine.camera.Camera;
import org.andengine.entity.scene.background.Background;
import org.andengine.entity.sprite.Sprite;
import org.andengine.opengl.util.GLState;
import org.andengine.util.color.Color;

import androidlab.sprintingsquirrel.BaseScene;
import androidlab.sprintingsquirrel.SceneManager.SceneType;

public class SplashScene extends BaseScene{

	private Sprite splash;
	
	@Override
	public void createScene() {
		setBackground(new Background(Color.YELLOW));
		
		splash = new Sprite(0, 0, resourceManager.splashTR, vbom)
		{
		    @Override
		    protected void preDraw(GLState pGLState, Camera pCamera) 
		    {
		       super.preDraw(pGLState, pCamera);
		       pGLState.enableDither();
		    }
		};
		
		splash.setPosition((camera.getWidth()-splash.getWidth())/2, (camera.getHeight()-splash.getHeight())/2);
		attachChild(splash);
	}

	@Override
	public void onBackKeyPressed() {
		System.exit(0);
	}

	@Override
	public SceneType getSceneType() {
		return SceneType.SPLASH;
	}

	@Override
	public void disposeScene() {
		splash.detachSelf();
		splash.dispose();
		this.detachSelf();
		this.dispose();
	}

}
